import {defineStore} from "pinia";
import {GlobalSetting} from "@/ts/setting";
import {SchemeClassification} from "@/ts/scheme";
import {getCfListPage} from "@/api/classification/ClassificationApi";

export default defineStore("globalSetting",{
    state:()=>{
        const globalSetting:GlobalSetting={
            showKeyboard: false,
            playAudio:true,
            showKeyboardAdvice:true,
            showProgress:true,
            showAccuracy: true,
            showErrorNum: true,
            showSpeed: true,
            showSpendTime: true
        }
        const classificationOptions:SchemeClassification[]=[]
        return{
            globalSetting,
            page:{
                pageSize:0
            },
            classificationOptions
        }
    },
    actions:{
        getClassificationOptions(){
            getCfListPage(1).then(resp=>{
                // @ts-ignore
                if(resp.code === 200){
                    this.classificationOptions=resp.data.records
                }
            })
        }
    },

    persist:{
        enabled:true
    }
})